package montaltoController

import _root_.montaltoGrids.{GridIteratorCreator, Grid}
import _root_.montaltoNeds.NedBuilder
import scala.collection.mutable.Stack
import _root_.montaltoUtils._
/**
 * Created by IntelliJ IDEA.
 * User: Andrew Montalto
 * Date: May 2, 2010
 * Time: 4:45:58 PM
 * To change this template use File | Settings | File Templates.
 */

abstract class PopulateGrid(grid:Grid, total:Int){
  val t = total
  val g = grid
  def populate

}
class PopulateGridRandom(grid:Grid,total:Int) extends PopulateGrid(grid:Grid,total:Int){
   def populate()={
     var xStack:Stack[Int]=new Stack
     var yStack:Stack[Int]=new Stack
     for(i<-0 to t ){
       xStack.push(RandomSingleton.INSTANCE.nextPosInt(g._size))
       yStack.push(RandomSingleton.INSTANCE.nextPosInt(g._size))
     }
     while(!xStack.isEmpty)  {
       g.gridArray(xStack.pop)(yStack.pop).settleNed(NedBuilder.random)
     }
   }
}

class PopulateGridEvenXs(grid:Grid,total:Int) extends PopulateGrid(grid:Grid,total:Int){
  def populate()={
    var tempT = this.t
    val myIter = GridIteratorCreator.create(g)
      while(myIter.hasNext && total > -1){
       if(myIter.current().coodinate.x % 2 ==0){
         myIter.current().settleNed(NedBuilder.random)
       }
       myIter.next
       tempT = tempT -1
    }
  }
}